/*
 * Created on 2006-2-18
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.hitrust.gs.net;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.util.exception.GSException;

/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSAuditConstants {

    /*
     * 远端服务器访问方式
     */
    //public static final String schema="http";
    //public final String schema = GSSystemConfigurator.getParam("gs.auth.schema");

    /*
     * 远端服务器地址 
     */
    //public static final String host="61.152.242.72";
    //public final String host = GSSystemConfigurator.getParam("gs.auth.host");
    /*
     * 远端服务器开放的访问端口
     */
    //public static final String port ="7001";
    //public final String port = GSSystemConfigurator.getParam("gs.auth.port");
    /*
     * 远端服务器工程名
     */
    //public static final String fullPath = "v3/back/down";
    //public final String fullPath = GSSystemConfigurator.getParam("gs.auth.fullpath");
    /*
     * 本地对帐文件存放地址
     */
    //public static final String savePath = "c:/"; 
    //public final String savePath = GSSystemConfigurator.getParam("gs.auth.savepath");
    /*
     * 指定的处理时间 220000表示下午22点00分00秒
     */
    //public static final int PROCESS_TIME = 220000; 
    //public final int PROCESS_TIME = Integer.parseInt(GSSystemConfigurator.getParam("gs.auth.processtime"));
    
    
    public static String purCode = GSSystemConfigurator.getParam("gs.purcode");
    public static String ORDER_DETAIL_FILE_NAME = purCode + "_JYPT_AllItems_";
    public static String ORDER_DETAIL_DELIVER_CONFIRM_FILE_NAME = purCode + "_JYPT_ItemsDoing_";
    public static String ORDER_DETAIL_DELIVER_CANCEL_FILE_NAME = purCode + "_JYPT_ItemsCancel_";
    public static String ORDER_DETAIL_DELIVER_REFUSED_FILE_NAME = purCode + "_JYPT_ItemsRefused_";
    public static String ORDER_DETAIL_CONSIGN_CONFIRM_FILE_NAME = purCode + "_JYPT_ItemsFinished_";
    
    public static int ALLITEMS = 1;
    public static int ITEMSDOING = 2;
    public static int ITEMSREFUSED = 3;
    public static int ITEMSFINISHED = 4;
    public static int ITEMSCANCEL = 5;

/*    
    public  static String getCurrentDate() throws GSException {
        GSAuditDAO dao = new GSAuditDAO();
        Connection conn = null;
        try{
	        conn = dao.getConnetion();
	        PreparedStatement pstmt = conn.prepareStatement("select GS_AUDIT_DATE from GS_AUDIT_DATE ");
	        ResultSet rs = pstmt.executeQuery();
	        rs.next();String nowDateStr = rs.getString("1");
	        rs.close();pstmt.close();
	        return nowDateStr;
        }catch(SQLException sqle){
            throw new GSException(GSException.BME00001,GSException.BME00001_MSG);
        }finally{
            dao.close(conn);
        }
    }
*/
    public static String getCurrentDate()  {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String date = sdf.format(new Date(System.currentTimeMillis()));
        
        return date;
    }

    public static File getFile(String date,int type) throws GSException {
        File file = null;
        file = new File(getFileName(date,type));
        return file;
    }
    
    public static String getFileNameSimple(String date,int type) throws GSException {
        String value = "";
        switch(type){
        case 1:
            value = ORDER_DETAIL_FILE_NAME + date + ".xls";
            break;
        case 2:
            value = ORDER_DETAIL_DELIVER_CONFIRM_FILE_NAME + date + ".xls";
            break;
        case 3:
            value = ORDER_DETAIL_DELIVER_REFUSED_FILE_NAME + date + ".xls";
            break;
        case 4:
            value = ORDER_DETAIL_CONSIGN_CONFIRM_FILE_NAME + date + ".xls";
            break;
        case 5:
            value = ORDER_DETAIL_DELIVER_CANCEL_FILE_NAME + date + ".xls";
            break;
        }
        
        return value;
        
    }
    
    public static String getFileName(String date,int type) throws GSException {
        String value = "";
        switch(type){
        case 1:
            value = GSSystemConfigurator.getParam("gs.auth.savepath") + System.getProperty("file.separator") + ORDER_DETAIL_FILE_NAME + date + ".xls";
            break;
        case 2:
            value = GSSystemConfigurator.getParam("gs.auth.savepath") + System.getProperty("file.separator") + ORDER_DETAIL_DELIVER_CONFIRM_FILE_NAME + date + ".xls";
            break;
        case 3:
            value = GSSystemConfigurator.getParam("gs.auth.savepath") + System.getProperty("file.separator") + ORDER_DETAIL_DELIVER_REFUSED_FILE_NAME + date + ".xls";
            break;
        case 4:
            value = GSSystemConfigurator.getParam("gs.auth.savepath") + System.getProperty("file.separator") + ORDER_DETAIL_CONSIGN_CONFIRM_FILE_NAME + date + ".xls";
            break;
        case 5:
            value = GSSystemConfigurator.getParam("gs.auth.savepath") + System.getProperty("file.separator") + ORDER_DETAIL_DELIVER_CANCEL_FILE_NAME + date + ".xls";
            break;
        }
        
        return value;
    }
}
